/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modulo1.cgt;

import modulo1.cdp.Aluno;
import modulo1.cdp.Professor;
import modulo1.cgd.AlunoDaoJpa;
import modulo1.cgd.ProfessorDaoJpa;

/**
 *
 * @author ifes
 */
public class LoginApl {

   private static LoginApl instance;

    public static LoginApl getInstance() {
        if (instance == null) {
            instance = new LoginApl();
        }
        return instance;
    }
    
    public boolean consultarProfessor(String cpf, String senha){
        ProfessorDaoJpa pdj = new ProfessorDaoJpa();
        try{
           Professor professor = pdj.verificarProfessor(cpf, senha); 
           if(professor == null)
               return false;
           return true;
        }catch(Exception e){
            //e.printStackTrace();
            return false;
        }
    }
    
    public Aluno alunoLogon(String matricula, String senha) throws Exception {
        try {
            AlunoDaoJpa cdj = new AlunoDaoJpa();
            Aluno c = cdj.buscarLogon(matricula, senha);
            return c;
        } catch (Exception ex) {
            throw new Exception("Erro ao fazer logon.");
        }
    }
}
